//
//  LDYtabbarMainViewController.swift
//  李东阳微博
//
//  Created by 李东阳 on 16/4/16.
//  Copyright © 2016年 李东阳. All rights reserved.
//

import UIKit

class LDYtabbarMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabbar = LDYTabbar()
        
        tabbar.ldyDelegate = self
        
        setValue(tabbar, forKey: "tabBar")
        
            //MARK: -  添加首页控制器
        addChildViewController(LDYHomeTableViewController(), ImageName: "tabbar_home", title: "首页")
  
            //MARK: -  添加消息控制器

        addChildViewController(LDYMessageTableViewController(), ImageName: "tabbar_message_center", title: "消息")
        
            //MARK: -  添加发现控制器
        addChildViewController(LDYDiscoverTableViewController(), ImageName: "tabbar_discover", title: "发现")
        
            //MARK: -  添加我的控制器
        addChildViewController(LDYProfileTableViewController(), ImageName: "tabbar_profile", title: "我的")
        
    }

    

    func addChildViewController(childController: UIViewController, ImageName:String, title:String) {
        
      

        //设置图片
        childController.tabBarItem.image = UIImage(named:ImageName)
        //设置选中图片
        childController.tabBarItem.selectedImage = UIImage(named: "\(ImageName)_selected")
            //MARK: - 设置title
        childController.title = title
            //MARK: -  添加子控制器
        addChildViewController(UINavigationController(rootViewController: childController))

        
    }
    
 
}
extension LDYtabbarMainViewController:LDYTabbarDelegate{


    func composeButtonClick() {
        print("中间那妞")
      presentViewController( UINavigationController(rootViewController: LDYComposeViewController()), animated: true, completion: nil)
    
    }

}





